﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using FairyGUI;
using DG.Tweening;
using UnityEngine;

namespace MDFGame
{
    public abstract class AreaUIView
    {
        protected AreaUIComponent ACom;
        public GComponent MainUI;
        public GLoader AreaPic;
        public Controller AreaControl;
        protected Sequence Sequence;


        public void Create(GComponent UI,AreaUIComponent acom)
        {
            Sequence = DOTween.Sequence();
            ACom = acom;
            MainUI = UI;
            MainUI.SetPivot(0.5f,0.5f,true);
            AreaPic = MainUI.GetChild("n0").asLoader;
            //AreaControl = MainUI.GetController("");
            MainUI.touchable = true;
            MainUI.draggable = false;


            MainUI.onClick.Add(OnClick);

            MainUI.onRollOver.Add(OnRollIn);
            MainUI.onRollOut.Add(OnRollOut);

            MainUI.AddEventListener("CardIn",CardIn);
        }
        public Vector2 GetPosition()
        {
            return new Vector2(MainUI.x,MainUI.y);
        }


        protected virtual void OnClick()
        {

        }

        protected virtual void OnRollIn()
        {

        }

        protected virtual void OnRollOut()
        {

        }

        protected void CardIn(EventContext context)
        {
            Log.Info($"卡片进入{ACom.Parent.GetComponent<AreaInfoComponent>().AreaType}");
        }
        /// <summary>
        /// 手动卡片进入
        /// </summary>
        /// <param name="card"></param>
        public virtual void CardIn(Entity card) { }
        /// <summary>
        /// 手动卡片离开
        /// </summary>
        public virtual void CardLeave() { }
        /// <summary>
        /// 针对卡片特有UI的操作
        /// </summary>
        public virtual void CardUIOperator(object[] o) { }
        public abstract void AreaWork();
    }
}
